<template>
  <div class="comment">
    <!-- 表格 -->
    <el-table :data="comment">
      <el-table-column prop="id" label="编号" width="80" />
      <el-table-column prop="commenTime" label="发表/评论时间" />
      <el-table-column prop="orderId" label="订单ID" />
      <el-table-column prop="userId" label="顾客ID" />
      <el-table-column prop="parentId" label="是否为追评" />
      <el-table-column prop="score" label="服务打分" />
      <el-table-column prop="content" label="评论" />
      <el-table-column prop="status" label="状态" />
      <el-table-column label="操作" fixed="right">
        <template slot-scope="scope">
          <el-button type="primary" size="small" @click="shenhe(scope.row)">审核</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 表格结束 -->
    <!-- 模态框 -->
    <el-dialog title="评论审核" :visible.sync="visible">
      <p>用户名：{{this.com.idn}}</p>
      <p>评论：{{this.com.content}}</p>
      <!--按钮-->
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submit">审核通过</el-button>
        <el-button type="danger" @click="refuse">拒绝审核</el-button>
      </div>
    </el-dialog>
    <!-- 模态框结束 -->
  </div>
</template>

<script>
import { get } from "@/utils/request";
export default {
  data() {
    return {
      visible: false,
      comment: [],
      com: []
    };
  },
  created() {
    this.loadComment();
  },
  methods: {
    loadComment() {
      let url = "http://47.95.112.55:8888/comment/findAllComments";
      get(url).then(response => {
        this.comment = response.data;
      });
    },
    shenhe(row) {
      this.com = row;
      this.visible = true;   //打开模态框
    },
    submit() {
      let url = "http://47.95.112.55:8888/comment/auditing";
      get(url, { id: this.com.id }).then(response => {
        this.$message({ type: "success", message: response.message });
        this.loadComment();
      });
      this.visible = false;
    },
    refuse() {
      let url = "http://47.95.112.55:8888/comment/refuseauditing";
      get(url, { id: this.com.id }).then(response => {
        this.$message({ type: "success", message: response.message });
        this.loadComment();
      });
      this.visible = false;
    }
  }
};
</script>
